package com.itheima.controller;

import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/checkOrder",name = "体检预约模块")
public class CheckOrderController {

    @Reference
    private SetMealService setMealService;

    @RequestMapping(value = "/findAllSetMeal.do",name = "/查询所有套餐")
    public Result findAllSetMeal(@RequestBody QueryPageBean queryPageBean){
        try {
            //调用生产者查询所有
            Map map = setMealService.findAllSetMeal(queryPageBean);
            //查询成功
            return new Result(true,"查询套餐成功",map);
        } catch (Exception e) {
            e.printStackTrace();
            //查询失败
            return new Result(false,"查询套餐失败");
        }

    }

    @RequestMapping(value = "/findSetMealDetailById.do",name = "/根据id查询单个套餐详情")
    public Result findSetMealDetailById(String id){
        try {
            //调用生产者查询
            Setmeal setmeal = setMealService.findSetMealDetailById(id);
            //查询成功
            return new Result(true,"查询套餐详情成功",setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            //查询失败
            return new Result(false,"查询套餐详情失败");
        }

    }
}
